package pers.cloud.ocr.tencent.config;


import pers.cloud.orc.throwable.MyCloudOCRException;

public class TencentORCConfig {

    public TencentORCConfig() {
    }

    public TencentORCConfig(TencentORCConfig tencentORCConfig) {
        this.appId = tencentORCConfig.appId;
        this.secretId = tencentORCConfig.secretId;
        this.secretKey = tencentORCConfig.secretKey;
    }

    private Integer appId;// 腾讯云API签名中的APPID
    private String secretId;// 腾讯云API签名中的SecretId
    private String secretKey;// 腾讯云中API签名的SecretKey

    public Integer getAppId() {
        return appId;
    }

    public String getSecretId() {
        return secretId;
    }

    public String getSecretKey() {
        return secretKey;
    }

    public static class Builder{
        private TencentORCConfig tencentORCConfig;
        public Builder(){
            tencentORCConfig = new TencentORCConfig();
        }

        public Builder addAppId(Integer appId){
            tencentORCConfig.appId = appId;
            return this;
        }

        public Builder addSecretId(String secretId){
            tencentORCConfig.secretId = secretId;
            return this;
        }

        public Builder addSecretKey(String secretKey){
            tencentORCConfig.secretKey = secretKey;
            return this;
        }

        /**
         * 构建腾讯orc识别配置
         * @return 腾讯orc识别配置
         * @throws MyCloudOCRException
         */
        public TencentORCConfig build() throws MyCloudOCRException {
            if(tencentORCConfig.appId == null){
                throw new MyCloudOCRException("APPID不能为空！");
            }
            if(tencentORCConfig.secretKey == null){
                throw new MyCloudOCRException("secretKey不能为空！");
            }
            if(tencentORCConfig.secretId == null){
                throw new MyCloudOCRException("secretId不能为空！");
            }
            return new TencentORCConfig(tencentORCConfig);
        }
    }
}
